package source.model.utility;

import source.model.DataHandler;
import source.model.type.*;
import source.model.Terrain;
import source.model.*;
import source.model.Planet;
import source.model.Position;
import source.model.AreaEffect;
import source.model.Tile;
import source.model.AreaEffect_Heal;
import source.model.AreaEffect_InstantDeath;
import source.model.AreaEffect_Teleport;

public class MapGenerator {
		
		public static void createDefaultMap(DataHandler dh)
		{

			//add planets
			dh.addGameObject(new Planet(), new Position(1,1));
			dh.addGameObject(new Planet(), new Position(3,1));
			dh.addGameObject(new Planet(), new Position(1,3));
			dh.addGameObject(new Planet(), new Position(8,6));
			dh.addGameObject(new Planet(), new Position(6,8));
			dh.addGameObject(new Planet(), new Position(8,8));
			//add slow terrain
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(7,7));
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(6,6));
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(5,5));
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(4,4));
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(3,3));
			dh.addGameObject(new Terrain(TerrainType.IONSTORM), new Position(2,2));
			//add impassable terrain
			dh.addGameObject(new Terrain(TerrainType.SOLARWIND), new Position(2,5));
			dh.addGameObject(new Terrain(TerrainType.SOLARWIND), new Position(2,6));
			dh.addGameObject(new Terrain(TerrainType.SOLARWIND), new Position(7,3));
			dh.addGameObject(new Terrain(TerrainType.SOLARWIND), new Position(7,4));
			//add AreaEffects		
			//TODO:  Figure out how to add AreaEffects.  Apparently AreaEffect is now abstract
			dh.addGameObject(new AreaEffect_Heal(AreaEffect_ModHealth_Type.HEAL1), new Position(0,1));
			dh.addGameObject(new AreaEffect_Heal(AreaEffect_ModHealth_Type.DAMAGE1), new Position(1,2));
			//dh.addGameObject(new AreaEffect_InstantDeath(AreaEffect_InstantDeath_Type.INSTANTDEATH1), new Position(1,0));
			dh.addGameObject(new AreaEffect_Teleport(AreaEffect_Teleport_Type.TELEPORT, new Position(4, 4)), new Position(2, 2));	
			dh.addGameObject(new AreaEffect_Teleport(AreaEffect_Teleport_Type.TELEPORT, new Position(2, 2)), new Position(4, 4));
			//add Items
			dh.addGameObject(new Item(ItemType.COMET), new Position(4,6));
			dh.addGameObject(new CosmicDrill(), new Position(5,6));
			//dh.addGameObject(new DerelictOreRefinery(), new Position(2,8));
			dh.addGameObject(new Laser(), new Position(6,1));
			dh.addGameObject(new CountDownItem(), new Position(9,3));
			
			for(int i=0; i<Position.xBound; i++)
			{
				for(int j=0; j<Position.yBound; j++)
				{
					Position p = new Position(i,j);
					Tile newPosTile = dh.positionQuery( p );
					if(newPosTile.getTerrain() == null)
					{
						dh.addGameObject(new Terrain(TerrainType.VOID), p);
					}
				}
			}
		}
}
